home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gxclpage.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  3.8 KB  |  122 lines

  1. /* Copyright (C) 1997 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gxclpage.c,v 1.2 2000/09/19 19:00:35 lpd Exp $ */
  20. /* Page object management */
  21. #include "gdevprn.h"
  22. #include "gxcldev.h"
  23. #include "gxclpage.h"
  24.  
  25. /* Save a page. */
  26. int
  27. gdev_prn_save_page(gx_device_printer * pdev, gx_saved_page * page,
  28.            int num_copies)
  29. {
  30.     /* Make sure we are banding. */
  31.     if (!pdev->buffer_space)
  32.     return_error(gs_error_rangecheck);
  33.     if (strlen(pdev->dname) >= sizeof(page->dname))
  34.     return_error(gs_error_limitcheck);
  35.     {
  36.     gx_device_clist_writer * const pcldev =
  37.         (gx_device_clist_writer *)pdev;
  38.     int code;
  39.  
  40.     if ((code = clist_end_page(pcldev)) < 0 ||
  41.         (code = clist_fclose(pcldev->page_cfile, pcldev->page_cfname, false)) < 0 ||
  42.         (code = clist_fclose(pcldev->page_bfile, pcldev->page_bfname, false)) < 0
  43.         )
  44.         return code;
  45.     /* Save the device information. */
  46.     memcpy(&page->device, pdev, sizeof(gx_device));
  47.     strcpy(page->dname, pdev->dname);
  48.     /* Save the page information. */
  49.     page->info = pcldev->page_info;
  50.     page->info.cfile = 0;
  51.     page->info.bfile = 0;
  52.     }
  53.     /* Save other information. */
  54.     page->num_copies = num_copies;
  55.     return (*gs_clist_device_procs.open_device) ((gx_device *) pdev);
  56. }
  57.  
  58. /* Render an array of saved pages. */
  59. int
  60. gdev_prn_render_pages(gx_device_printer * pdev,
  61.               const gx_placed_page * ppages, int count)
  62. {
  63.     gx_device_clist_reader * const pcldev =
  64.     (gx_device_clist_reader *)pdev;
  65.  
  66.     /* Check to make sure the pages are compatible with the device. */
  67.     {
  68.     int i;
  69.     gx_band_params_t params;
  70.  
  71.     for (i = 0; i < count; ++i) {
  72.         const gx_saved_page *page = ppages[i].page;
  73.  
  74.         /* We would like to fully check the color representation, */
  75.         /* but we don't have enough information to do that. */
  76.         if (strcmp(page->dname, pdev->dname) != 0 ||
  77.         memcmp(&page->device.color_info, &pdev->color_info,
  78.                sizeof(pdev->color_info)) != 0
  79.         )
  80.         return_error(gs_error_rangecheck);
  81.         /* Currently we don't allow translation in Y. */
  82.         if (ppages[i].offset.y != 0)
  83.         return_error(gs_error_rangecheck);
  84.         /* Make sure the band parameters are compatible. */
  85.         if (page->info.band_params.BandBufferSpace !=
  86.         pdev->buffer_space ||
  87.         page->info.band_params.BandWidth !=
  88.         pdev->width
  89.         )
  90.         return_error(gs_error_rangecheck);
  91.         /* Currently we require all band heights to be the same. */
  92.         if (i == 0)
  93.         params = page->info.band_params;
  94.         else if (page->info.band_params.BandHeight !=
  95.              params.BandHeight
  96.         )
  97.         return_error(gs_error_rangecheck);
  98.     }
  99.     }
  100.     /* Set up the page list in the device. */
  101.     /****** SHOULD FACTOR THIS OUT OF clist_render_init ******/
  102.     pcldev->ymin = pcldev->ymax = 0;
  103.     pcldev->pages = ppages;
  104.     pcldev->num_pages = count;
  105.     /* Render the pages. */
  106.     {
  107.     int code = (*dev_proc(pdev, output_page))
  108.         ((gx_device *) pdev, ppages[0].page->num_copies, true);
  109.  
  110.     /* Delete the temporary files. */
  111.     int i;
  112.  
  113.     for (i = 0; i < count; ++i) {
  114.         const gx_saved_page *page = ppages[i].page;
  115.  
  116.         clist_unlink(page->info.cfname);
  117.         clist_unlink(page->info.bfname);
  118.     }
  119.     return code;
  120.     }
  121. }
  122.